package gamagora.game.entity
{
	import org.flixel.FlxEmitter;
	import org.flixel.FlxParticle;

	public class OSEmitter extends OSEntity
	{
		protected var _particleEmitter:FlxEmitter
		
		public function OSEmitter(X:Number=0, Y:Number=0, nbParticles:Number = 0)
		{
			super(ANIMATION, X, Y);
			visible = false;
			
			_particleEmitter = new FlxEmitter(X, Y, nbParticles);
		}
		
		//Override
		
		public override function addToWorld():void
		{
			super.addToWorld();
			_world.add(_particleEmitter);
		}
		
		public override function removeFromWorld():void
		{
			super.removeFromWorld();
			_world.remove(_particleEmitter, true);
		}
		
		public override function update():void
		{
			super.update();
			_particleEmitter.update();
		}
		
		public override function draw():void
		{
			super.draw();
			_particleEmitter.draw();
		}
		
		public override function setStartX(decalX:Number):void
		{
			super.setStartX(decalX);
			_particleEmitter.x += decalX;
		}
		
		public override function kill():void
		{
			super.kill();
			_particleEmitter.kill();
		}
		
		public override function destroy():void
		{
			super.destroy();
			_particleEmitter.destroy();
		}
		
		//Delegates
		
		public function addParticle(particle:FlxParticle):void
		{
			_particleEmitter.add(particle);
		}
		
		public function start(Explode:Boolean=true,Lifespan:Number=0,Frequency:Number=0.1,Quantity:uint=0):void
		{
			_particleEmitter.start(Explode, Lifespan, Frequency, Quantity);
		}
		
		public function setXSpeed(Min:Number,Max:Number):void
		{
			_particleEmitter.setXSpeed(Min, Max);
		}
		
		public function setYSpeed(Min:Number,Max:Number):void
		{
			_particleEmitter.setYSpeed(Min, Max);
		}
		
		public function setGravity(gravity:Number):void
		{
			_particleEmitter.gravity = gravity;
		}
		
		public function getMaxSize():uint
		{
			return _particleEmitter.maxSize;
		}
	}
}
